package com.yunxin.yundubbo.interfaces;


import com.alibaba.fastjson2.JSON;
import com.yunxin.yundubbo.mode.Message;
import io.netty.channel.ChannelHandlerContext;

import java.nio.charset.StandardCharsets;

public interface DubboHandler {

    void handler(ChannelHandlerContext ctx, Message message);

    int getType();

    default  <T> T deserialization (byte[] bytes,Class<T> tClass){
       return JSON.parseObject(new String(bytes, StandardCharsets.UTF_8),tClass);
    }

    default byte[] serialization(Object object){
        String data = JSON.toJSONString(object);
        return data.getBytes();
    }
}
